package com.youkeyi.ddy.cloud.common.api.application.system.user;

import com.youkeyi.ddy.cloud.common.api.application.system.user.dto.SystemUserAuthLoginListCloudDto;
import com.youkeyi.ddy.cloud.common.api.application.system.user.dto.SystemUserDetailCloudDto;
import com.youkeyi.ddy.cloud.common.api.application.system.user.dto.SystemUserListByOrgCloudDto;
import com.youkeyi.ddy.cloud.common.api.application.system.user.dto.SystemUserListCloudDto;
import com.youkeyi.ddy.cloud.common.api.application.system.user.param.*;
import com.youkeyi.ddy.cloud.common.response.ResponseContent;
import io.swagger.annotations.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 系统用户
 *
 * @Useror liuxiawang
 * @Date 5/24/22 10:36 PM
 * @Location shenzhen.china
 */
@Api(tags = {"【SYSTEM】user management"})
@RestController
@FeignClient(value = "YOUKEYI-DDY-CLOUD-APPLICATION-SYSTEM", fallback = SystemUserCloudServiceFallback.class)
@RequestMapping("/system/user")
public interface SystemUserCloudService {

    // 查询用户列表
    @ApiOperation(value = "Query System User List", authorizations = {@Authorization("com.youkeyi.ddy.cloud.common.api.application.system.user.SystemUserCloudService.list")})
    @ApiResponse(code = 200, message = "data Property in Response Body", response = SystemUserListCloudDto.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", paramType = "query", value = "Param of Query System User List", dataType = "SystemUserListCloudParam", dataTypeClass = SystemUserListCloudParam.class),
    })
    @GetMapping
    public abstract SystemUserListCloudDto list(SystemUserListCloudParam param);

    // 查询用户列表
    @ApiOperation(value = "Query System User List", authorizations = {@Authorization("com.youkeyi.ddy.cloud.common.api.application.system.user.SystemUserCloudService.listByOrg")})
    @ApiResponse(code = 200, message = "data Property in Response Body", response = SystemUserListCloudDto.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", paramType = "query", value = "Param of Query System User List", dataType = "SystemUserListCloudParam", dataTypeClass = SystemUserListCloudParam.class),
    })
    @GetMapping("/listByOrg")
    public abstract SystemUserListByOrgCloudDto listByOrg(SystemUserListByOrgCloudParam param);

    // 查询用户详情
    @ApiOperation(value = "Query System User Detail", authorizations = {@Authorization("com.youkeyi.ddy.cloud.common.api.application.system.user.SystemUserCloudService.detail")})
    @ApiResponse(code = 200, message = "data Property in Response Body", response = SystemUserDetailCloudDto.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userPrimaryKey", paramType = "path", value = "Param of Query System User Detail", dataType = "String", dataTypeClass = String.class),
    })
    @GetMapping("/{userPrimaryKey}")
    public abstract SystemUserDetailCloudDto detail(@PathVariable("userPrimaryKey") String userPrimaryKey);

    // 创建用户
    @ApiOperation(value = "Create System User", authorizations = {@Authorization("com.youkeyi.ddy.cloud.common.api.application.system.user.SystemUserCloudService.create")})
    @ApiResponse(code = 200, message = "data Property in Response Body", response = ResponseContent.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", paramType = "body", value = "Param of Create System User", dataType = "SystemUserCreateCloudParam", dataTypeClass = SystemUserCreateCloudParam.class),
    })
    @PostMapping("/create")
    public abstract ResponseContent create(@RequestBody SystemUserCreateCloudParam param);


    // 更新密码
    @ApiOperation(value = "Update System User Password", authorizations = {@Authorization("com.youkeyi.ddy.cloud.common.api.application.system.user.SystemUserCloudService.updatePassword")})
    @ApiResponse(code = 200, message = "data Property in Response Body", response = ResponseContent.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", paramType = "body", value = "Param of Update System User Password", dataType = "SystemUserUpdatePasswordCloudParam", dataTypeClass = SystemUserUpdatePasswordCloudParam.class),
    })
    @PatchMapping("update/password")
    public abstract ResponseContent updatePassword(HttpServletRequest request, HttpServletResponse response, @RequestBody SystemUserUpdatePasswordCloudParam param);

    // 编辑用户
    @ApiOperation(value = "Update System User", authorizations = {@Authorization("com.youkeyi.ddy.cloud.common.api.application.system.user.SystemUserCloudService.update")})
    @ApiResponse(code = 200, message = "data Property in Response Body", response = ResponseContent.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", paramType = "body", value = "Param of Update System User", dataType = "SystemUserUpdateCloudParam", dataTypeClass = SystemUserUpdateCloudParam.class),
    })
    @PatchMapping("/update")
    public abstract ResponseContent update(@RequestBody SystemUserUpdateCloudParam param);


    // 删除用户
    @ApiOperation(value = "Delete System User", authorizations = {@Authorization("com.youkeyi.ddy.cloud.common.api.application.system.user.SystemUserCloudService.delete")})
    @ApiResponse(code = 200, message = "data Property in Response Body", response = ResponseContent.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", paramType = "query", value = "Param of Delete System User", dataType = "SystemUserDeleteCloudParam", dataTypeClass = SystemUserDeleteCloudParam.class),
    })
    @DeleteMapping("/delete")
    public abstract ResponseContent delete(SystemUserDeleteCloudParam param);

    // 编辑头像
    @ApiOperation(value = "Update avatar", authorizations = {@Authorization("com.youkeyi.ddy.cloud.common.api.application.system.user.SystemUserCloudService.updateAvatarUrl")})
    @ApiResponse(code = 200, message = "data Property in Response Body", response = ResponseContent.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", paramType = "body", value = "Param of Update avatar"),
    })
    @PatchMapping("/update/avatar")
    public abstract ResponseContent updateAvatarUrl(@RequestBody SystemUserUpdateCloudParam param);

    // 编辑用户昵称
    @ApiOperation(value = "Update System User", authorizations = {@Authorization("com.youkeyi.ddy.cloud.common.api.application.system.user.SystemUserCloudService.updateNickName")})
    @ApiResponse(code = 200, message = "data Property in Response Body", response = ResponseContent.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", paramType = "body", value = "Param of Update System User", dataType = "SystemUserUpdateCloudParam", dataTypeClass = SystemUserUpdateCloudParam.class),
    })
    @PatchMapping("/update/nick/name")
    public abstract ResponseContent updateNickName(@RequestBody SystemUserUpdateCloudParam param);






    // 查询用户授权登陆列表
    @ApiOperation(value = "Query User Auth List", authorizations = {@Authorization("com.youkeyi.ddy.cloud.common.api.application.system.user.SystemUserCloudService.authList")})
    @ApiResponse(code = 200, message = "data Property in Response Body", response = SystemUserAuthLoginListCloudDto.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", paramType = "query", value = "Param of Query System User List", dataType = "SystemUserAuthLoginListCloudParam", dataTypeClass = SystemUserAuthLoginListCloudParam.class),
    })
    @GetMapping("/auth")
    public abstract SystemUserAuthLoginListCloudDto authList(SystemUserAuthLoginListCloudParam param);
}
